﻿using System.Collections.Generic;
using Yz.Base;

namespace Yz.Core.Apis
{
    public class ApiDataFactory
    {
        public static ApiData<T> CreateApiData<T>(T model, string code = ApiDataCode.success,
            string msg = ApiDataMsg.success, int total = 0) where T : BaseModel
        {
            return new ApiData<T>
            {
                errcode = code,
                errmsg = msg,
                total = total,
                data = model
            };
        }

        public static ApiData<List<T>> CreateApiData<T>(List<T> models, string code = ApiDataCode.success,
            string msg = ApiDataMsg.success, int total = 0) where T : BaseModel
        {
            return new ApiData<List<T>>
            {
                errcode = code,
                errmsg = msg,
                total = total,
                data = models
            };
        }
    }
}
